<?php

namespace Config;

// Create a new instance of our RouteCollection class.
$routes = Services::routes();

// Load the system's routing file first, so that the app and ENVIRONMENT
// can override as needed.
if (file_exists(SYSTEMPATH . 'Config/Routes.php'))
{
	require SYSTEMPATH . 'Config/Routes.php';
}

/**
 * 路由器设置
 */
$routes->setDefaultNamespace('App\Controllers');
$routes->setDefaultController('Home');
$routes->setDefaultMethod('index');
$routes->setTranslateURIDashes(false);
$routes->set404Override();
$routes->setAutoRoute(true);

/*
 * 自定义路由
 */
// 后台首页(用来加载框架的)
$routes->get('index', 'admin\Home::index', ['filter' => 'adminAuth']);
// 实际的右侧的首页
$routes->get('dashboard', 'admin\Home::dashboard', ['filter' => 'adminAuth']);
$routes->get('index2', 'admin\Home::index2', ['filter' => 'adminAuth']);
$routes->get('index3', 'admin\Home::index3', ['filter' => 'adminAuth']);
// 登录
$routes->match(['get','post'], 'login', 'admin\Auth::login');
// 注册
$routes->match(['get','post'],'register', 'admin\Auth::register', ['filter' => 'adminNoAuth']);
// 退出
$routes->get('logout', 'admin\Auth::logout');
// 个人资料
$routes->match(['get','post'],'profile', 'admin\Auth::profile',['filter' => 'adminAuth']);

// 后台
$routes->group('admin', ['filter' => 'adminAuth'], function($routes)
{
    // 修改密码
    $routes->match(['get','post'],'password', 'admin\Auth::password');
    // 个人资料
    $routes->match(['get','post'],'info', 'admin\Auth::info');
    // 管理员列表
    $routes->get('admintor', 'admin\Admintor::index');
});


/*
 * --------------------------------------------------------------------
 * 附加路由
 * --------------------------------------------------------------------
 * 经常会有一些时候，你需要额外的路由，而你需要它能够覆盖此文件中的任何默认值 *
 * You will have access to the $routes object within that file without needing to reload it.
 */
if (file_exists(APPPATH . 'Config/' . ENVIRONMENT . '/Routes.php'))
{
	require APPPATH . 'Config/' . ENVIRONMENT . '/Routes.php';
}